// 修改密码窗口
var changePwdWin = new CQCIS.Window({
    id: 'changePwdWin',
    title: '修改密码',
    width: 240,
    height: 150,
    draggable: false,
    resizable: false,
    closable: false,
    items: new CQCIS.form.DWRForm({
        dwr: {
            load: Ext.emptyFn,
            save: function(values) {
                var record = changePwdWin.getBasicForm().getValues();
                smDwr.updateWorkerPwd(record.workerID, record.workerPwd, record.preWorkerPwd, function(result) {
                    if (result.flag && result.flag == 'true') {
                        smDwr.doLogoff(function() {
                            changePwdWin.hide();
                            Ext.Msg.alert('提示', '密码修改成功，请以新的密码登录系统！', function() {
                                location.reload();
                            });
                        });
                    } else {
                        CQCIS.msg(result.msg);
                        changePwdWin.getBasicForm().reset();
                        changePwdWin.getBasicForm().isValid();
                    }
                    changePwdWin.getForm().afterRemote();
                });
            }
        },
        items: [{
            name: 'workerID',
            xtype: 'hidden'
        }, {
            fieldLabel: '当前密码',
            name: 'preWorkerPwd',
            allowBlank: false,
            inputType: 'password',
            minLength: 6,
            maxLength: 12
        }, {
            fieldLabel: '新 密 码',
            name: 'workerPwd',
            allowBlank: false,
            inputType: 'password',
            minLength: 6,
            maxLength: 12
        }, {
            fieldLabel: '重复密码',
            name: '_reWorkerPwd',
            allowBlank: false,
            inputType: 'password',
            minLength: 6,
            maxLength: 12,
            validator: function(val) {
                if (changePwdWin.getBasicForm().getValues().workerPwd != val) {
                    return '两次输入的密码不一致！';
                } else {
                    return true;
                }
            }
        }]
    })
});
